package com.ilink.groundservice.mapper.langflowApp;


import com.ilink.groundservice.entity.PO.langflowApp.StoreFlowTag;
import java.util.List;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

@Mapper
public interface StoreFlowTagMapper {

    @Select("SELECT * FROM tb_flow_tag WHERE tag_id = #{tagId}")
    public List<StoreFlowTag> getStoreFlowTagsByTagId(String flowId);

    @Select("SELECT COUNT(*) FROM tb_flow_tag WHERE flow_id = #{flowId} AND tag_id = #{tagId}")
    public boolean existStoreFlowTag(String flowId, String tagId);

    @Select("SELECT * FROM tb_flow_tag WHERE flow_id = #{flowId}")
    public List<StoreFlowTag> getStoreFlowTagsByFlowId(String flowId);

    @Select("SELECT * FROM tb_flow_tag WHERE flow_id = #{flowId} AND tag_id = #{tagId}")
    public StoreFlowTag getStoreFlowTagById(String flowId, String tagId);

    @Insert("INSERT INTO tb_flow_tag (flow_id, tag_id) VALUES (#{flowId}, #{tagId})")
    public void insertStoreFlowTag(String flowId, String tagId);

    @Delete("DELETE FROM tb_flow_tag WHERE flow_id = #{flowId} AND tag_id = #{tagId}")
    public void deleteStoreFlowTag(String flowId, String tagId);

    @Select("SELECT tag_id FROM tb_flow_tag WHERE flow_id = #{flowId}")
    List<String> getTagIdsByFlowId(String flowId);

    @Select("SELECT flow_id FROM tb_flow_tag WHERE tag_id = #{tagId}")
    List<String> getFlowIdsByTagId(String tagId);

    @Select("SELECT it.tag_name FROM tb_tag it " +
            "JOIN tb_flow_tag ict ON it.tag_id = ict.tag_id " +
            "WHERE ict.flow_id = #{flowId}")
    List<String> getTagsByflowId(String flowId);
}


